//
//  NSDate+Extend.h
//  EPTool
//
//  Created by shiqing guo on 2018/5/8.
//  Copyright © 2018年 云数动能科技. All rights reserved.
//

#import <Foundation/Foundation.h>

#define DEFAULT_DATE_FORMAT         @"yyyy-MM-dd"
#define DEFAULT_TIME_FORMAT         @"hh:mm:ss"
#define DEFAULT_DATETIME_FORMAT     @"yyyy-MM-dd hh:mm"
#define DEFAULT_DATETIME_24HFORMAT        @"yyyy-MM-dd HH:mm" // 24时制
#define DEFAULT_DATETIME_POINT_FORMAT     @"yyyy.MM.dd"

@interface NSDate (Extend)

- (NSString *)transformDateForListCell;

- (NSString *)transformDateForMainCell;

- (NSString *)promptDateString;


/**
 *  时间转换
 *
 *  @param timeSince1970 1970标准时间
 *
 *  @return 2001标准时间
 */
+ (NSTimeInterval)timeSinceReferenceWithTimeSince1970:(NSTimeInterval)timeSince1970;
+ (NSTimeInterval)timeSinceReferenceWithTimeSince2001:(NSTimeInterval)timeSince2001;

//获取年月日如:19871127.
- (NSString *)getFormatYearMonthDay;

//返回当前月一共有几周(可能为4,5,6)
- (int )getWeekNumOfMonth;
//该日期是该年的第几周
- (int )getWeekOfYear;
//返回day天后的日期(若day为负数,则为|day|天前的日期)
- (NSDate *)dateAfterDay:(int)day;
//month个月后的日期
- (NSDate *)dateAfterMonth:(int)month;
//获取日
- (NSUInteger)getDay;
//获取月
- (NSUInteger)getMonth;
//获取年
- (NSUInteger)getYear;
//获取小时
- (NSUInteger)getHour;
//获取分钟
- (NSUInteger)getMinute;
//获取日
- (NSString *)getDayString;
//获取月
- (NSString *)getMonthString;
//获取年
- (NSString *)getYearString;
//获取小时
- (NSString *)getHourString;
//获取分钟
- (NSString *)getMinuteString;
- (NSInteger)getHour:(NSDate *)date;
- (NSInteger)getMinute:(NSDate *)date;

- (NSUInteger)daysAgo;
//午夜时间距今几天
- (NSUInteger)daysAgoAgainstMidnight;
- (NSString *)stringDaysAgo;
- (NSString *)stringDaysAgoAgainstMidnight:(BOOL)flag;
//返回一周的第几天(周末为第一天)
- (NSUInteger)weekday;
- (NSString *)strWeekday;
- (NSString *)strWeekDayWithPrefix:(NSString *)strPre;

//转为NSString类型的
+ (NSDate *)dateFromString:(NSString *)string;
+ (NSDate *)dateFromString:(NSString *)string withFormat:(NSString *)format;
+ (NSDate *)dateFromDate:(NSDate *)date withFormat:(NSString *)format;
+ (NSString *)stringFromDate:(NSDate *)date withFormat:(NSString *)string;
+ (NSString *)stringFromString:(NSString *)string withInFormat:(NSString *)inFormat andOutFormat:(NSString *)outFormat;
+ (NSString *)stringFromDate:(NSDate *)date;
+ (NSString *)stringForDisplayFromDate:(NSDate *)date;
+ (NSString *)stringForDisplayFromDate:(NSDate *)date prefixed:(BOOL)prefixed;

- (NSString *)string;
- (NSString *)chString;
- (NSString *)dateString;
- (NSString *)stringWithFormat:(NSString *)format;
- (NSString *)stringWithDateStyle:(NSDateFormatterStyle)dateStyle timeStyle:(NSDateFormatterStyle)timeStyle;

//返回该月的第一天
- (NSDate *)beginningOfMonth;
// 获取该周的周一（中国算法）
- (NSDate *)getMonday;
//返回当前天的年月日.
- (NSDate *)beginningOfDay;
//返回当前周的开始时间(周一作为本周最后一天)
- (NSDate *)beginningOfWeek;
//返回当前周的周末(周日作为本周最后一天)
- (NSDate *)endOfWeek;
//返回离当前时间几天后的本周第一天(周一作为本周第一天)
- (NSDate *)beginOfWeekWithBetweenDay:(NSInteger)betweenDay;
//返回离当前时间几天后的本周最后一天(周天作为本周最后一天)
- (NSDate *)endOfWeekWithBetweenDay:(NSInteger)betweenDay;
// 返回当前周的周天
- (NSInteger)sundayOfWeek;
// 返回当前周的周六
- (NSInteger)SaturdayOfWeek;
//该月的最后一天
- (NSDate *)endOfMonth;

+ (NSString *)dateFormatString;
+ (NSString *)timeFormatString;
+ (NSString *)timestampFormatString;
+ (NSString *)dbFormatString;
+ (NSString *)chFormatString;


- (BOOL)isToday;

- (int)daysAgoWithToday;

+ (NSString *)getTodayDate;
+ (NSString *)getTodayWeekday;
+ (NSString *)getTodayWeekdayAndDate;

// 得到给定日期的那天开始即那天的零点
- (NSDate *)dateByMovingToBeginningOfDay;

// 是否为下周（周一为第一天，周日为最后一天）
+ (BOOL)isNextWeek:(UInt64)UInt64Date;

// 获取昨天的日期
+ (NSDate *)getYesterdayDay:(NSDate *)aDate;
// 获取明天的日期
+ (NSDate *)getTomorrowDay:(NSDate *)aDate;
// 获取几天后的日期
+ (NSString *)getStrDate:(NSString *)strDate betweenDays:(NSInteger)days withFormat:(NSString *)strFormat;
// 获取上个月的日期
+ (NSDate *)getLastMonth:(NSDate *)aDate;
// 获取当前日期是星期几
+ (NSString *)strWeekDay:(NSString *)strDate withFormat:(NSString *)strFormat;

// 循环生成数字(年份)
+ (NSArray <NSString *>*)makeCycleNumberWithBegin:(NSUInteger)begin;

@end
